﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Telerik.Web.UI;
using AjaxControlToolkit;

namespace RedeSocial.Web.Controls
{
	[TargetControlType(typeof(RadTextBox))]
	public class RadTextBoxPasswordStrength : PasswordStrength
	{

		protected override void OnPreRender(EventArgs e)
		{

			base.OnPreRender(e);



			ScriptManager.RegisterStartupScript(Page, typeof(Page),

				"RadTextBoxPasswordStrength_getElementFix",

				GetClientObjectFixScript(),

				true);

		}



		private string GetClientObjectFixScript()
		{

			return String.Format("{0}\r\n{1}", @"
 
                var PSEB = Sys.Extended.UI.PasswordStrengthExtenderBehavior;
 
                PSEB.prototype._dispose = PSEB.prototype.dispose;
 
                PSEB.prototype.dispose = function ()
 
                {
 
                    try { this._dispose.apply(this, arguments); } catch (e) { };
 
                }
 
                ", @"Sys.Extended.UI.PasswordStrengthExtenderBehavior.prototype.get_element = function ()
 
                {
 
                    var e = Sys.Extended.UI.PasswordStrengthExtenderBehavior.callBaseMethod(this, 'get_element');
 
                    return e.className === 'rdfd_' && !this._isDisposing ? document.getElementById(e.id + '_text') : e;
 
                };");

		}


	}

}